/**
 * 
 */
package com.zxc.redis.RCountDownLatch;

import org.redisson.Redisson;
import org.redisson.api.RCountDownLatch;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;

/**
 * @author Administrator
 *
 */
public class RCountDownLatchDemo {

	/**
	 * @param args
	 * @throws InterruptedException 
	 */
	public static void main(String[] args) throws InterruptedException {
		Config config = new Config();
		config
			//.setCodec(new FstCodec())
			.useSingleServer() //单例模式
			.setAddress("192.168.1.122:6379")//连接地址
			.setDatabase(1) // 数据库索引位置
			.setPassword("shijie99test") // 密码
			.setClientName("channelbatch") // 客户端名称
			;
		final RedissonClient redisson = Redisson.create(config);
		
		RCountDownLatch latch = redisson.getCountDownLatch("anyCountDownLatch");
		boolean res = latch.trySetCount(1);
		System.out.println("trySetCount为1："+res);
		long l = latch.getCount();
		System.out.println("getCount:"+l);
		try {
			System.out.println("await前。。。。。");
			latch.await();
			System.out.println("await后。。。。。");
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
		redisson.shutdown();

	}

}
